/*appController=angular.module("appController",[]);*/
/*
 用户列表控制器
 1.0 mouse 2016/07/15
 */
appController.controller('userListCtrl',['$scope',function($scope){
   /*$scope.test={ts:'asdf'};
   $scope.col = 'userName';
   $scope.desc = 0;
   $scope.date=[
      {userName:"张三",accoutN:"25486",identity:"500241199602205925",content:"18225443856",departm:"监管",duty:"监区长"},
      {userName:"李四",accoutN:"32545",identity:"500241199602555925",content:"18225443856",departm:"监管",duty:"监区长"},
      {userName:"王五",accoutN:"3234",identity:"500241199602205925",content:"18225443856",departm:"监管",duty:"监区长"},
      {userName:"周六",accoutN:"34654",identity:"500241199602205925",content:"18225443856",departm:"监管",duty:"监区长"},
      {userName:"周末",accoutN:"2346",identity:"500241199602205925",content:"18225443856",departm:"监管",duty:"监区长"}
   ]*/


}])
/*
 用户详情控制器
 1.0 mouse 2016/07/15
 */
appController.controller('userDetailCtrl',['$scope',function($scope){
   $scope.test={ts:'asdf'};
}]);
/*
 创建用户控制器
 1.0 mouse 2016/07/25
 */
appController.controller('creatUserCtrl',['$scope',function($scope){
  //获取所有部门
  util.get("getAllStructure.do",null,function(response){
      $scope.firstStructure=response.object;
  },function(){
  });
  //获取第二级部门
  $scope.firstOption=function(superId){
    $scope.firstSuperid="superId="+superId;
    $scope.secondShow=false;
    $scope.thirdShow=false;
    $scope.fourthShow=false;
    $scope.secondOptionId="";
    $scope.thirdOptionId="";
    $scope.fourthOptionId="";
    $scope.fifthShow=false;
    $scope.fifthOptionId="";
    util.post("getAllStructureBySuperId.do",$scope.firstSuperid,function(response){
      $scope.secondStructure=response.object;
      $scope.secondShow=response.status;
      $scope.getRole(superId);
    },function(){
      $scope.getRole(superId);
    });

  }
  //获取第三级部门
  $scope.secondOption=function(secSuperId){
    $scope.secondSuperid="superId="+secSuperId;
    $scope.thirdShow=false;
    $scope.fourthShow=false;
    $scope.thirdOptionId="";
    $scope.fourthOptionId="";
    $scope.fifthShow=false;
    $scope.fifthOptionId="";
    util.post("getAllStructureBySuperId.do",$scope.secondSuperid,function(response){
      $scope.thirdStructure=response.object;
      $scope.thirdShow=response.status;
      $scope.getRole(secSuperId);
    },function(){
      $scope.getRole(secSuperId);
    });
  }
  //获取第四级部门
  $scope.thirdOption=function(thirSuperId){
    $scope.thirdSuperid="superId="+thirSuperId;
    $scope.fourthShow=false;
    $scope.fourthOptionId="";
    $scope.fifthShow=false;
    $scope.fifthOptionId="";
    util.post("getAllStructureBySuperId.do",$scope.thirdSuperid,function(response){
      $scope.fourthStructure=response.object;
      $scope.fourthShow=response.status;
      $scope.getRole(thirSuperId);
    },function(){
      $scope.getRole(thirSuperId);
    });
  }
  //获取第五级部门
  $scope.fourthOption=function(fourthSuperId){
    $scope.fourthSuperid="superId="+fourthSuperId;
    $scope.fifthShow=false;
    $scope.fifthOptionId="";
    util.post("getAllStructureBySuperId.do",$scope.fourthSuperid,function(response){
      $scope.fifthStructure=response.object;
      $scope.fifthShow=response.status;
      $scope.getRole(fourthSuperId);
    },function(){
      $scope.getRole(fourthSuperId);
    });
  }
  $scope.fifthOption=function(fifSuperId){
    $scope.getRole(fifSuperId);
  }
  $scope.getRole=function(struId){
    $scope.lastId="structureId="+struId;
    util.post("getRoleByStructureId.do",$scope.lastId,function(response){
      $scope.role=response.object;
      
    },function(){
     
    });
  };
  //创建用户按钮
  $scope.creatUser=function(){
    jq("#creatUserModel").modal('show');
      //获取所有部门
  }

}]);